<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>添加员工页面</title>
  <link rel="stylesheet" href="../../layui-v2.6.8/layui/css/layui.css">
  <script  src="../../layui-v2.6.8/layui/layui.js"></script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>添加员工</legend>
</fieldset>
<form class="layui-form">
  <div class="layui-form-item">
    <label class="layui-form-label">姓名</label>
    <div class="layui-input-block">
      <input type="text" id="ename" required  lay-verify="required" placeholder="请输入员工的姓名" autocomplete="off" class="layui-input">
      <a href="../car/addDirver.html" class="layui-btn layui-btn-danger layui-btn-xs">添加司机信息</a>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">联系方式</label>
    <div class="layui-input-block">
      <input type="text" id="ephone" required  lay-verify="required" placeholder="请输入员工的联系方式" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">工资/月</label>
    <div class="layui-input-block">
      <input type="text" id="esalary" required  lay-verify="required" placeholder="请输入员工每月的工资" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">员工岗位</label>
    <div class="layui-input-block">
      <select id="epost" lay-verify="required">
        <option value=""></option>
        <option value="派送员">派送员</option>
        <option value="操作员">操作员</option>
        <option value="分公司经理">分公司经理</option>
        <option value="会计">会计</option>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">员工身份证号</label>
    <div class="layui-input-block">
      <input type="text" id="enumber" required  lay-verify="required" placeholder="请输入员工的身份证号" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" onclick="insert_1()">添加</button>
    </div>
  </div>
</form>
<script>
  function insert_1(){
    var $ = layui.$;
    var ename =$("#ename").val();
    var ephone =$("#ephone").val();
    var esalary =$("#esalary").val();
    var epost =$("#epost").val();
    var enumber =$("#enumber").val();
    console.log(ename);
    var data ={
      "ename":ename,
      "ephone":ephone,
      "esalary":esalary,
      "epost":epost,
      "enumber":enumber,
    }
    var layer = layui.layer;
    var url ="http://localhost:8080/addEmp";
    $.ajax({
      url:url,
      type:"get",
      dataType:"json",
      async:true,
      // cache:false,
      data:data,
      success: function(data){
        console.log(data)
        if (data.code == 0) {

          layer.msg("添加成功", {icon: 6,time:1800},function (){
            // location.href = '../car/addCar.html';
          });
          window.location.href ='EmpIndex.html';
        } else {
          layer.msg("添加失败", {icon: 5});
        }
      }
    });
  }
</script>
</body>
</html>